
import { tt } from "../ttapi_interface/ttapi.js"
import * as tt2 from "../ttapi_layer2/ttlayer2.js";
import { MainUI } from "./MainUI.js";
import { EUI_Style } from "./eui/EUI_Style.js";



//Edit 并不适合于状态机模式，只是我的App框架中 只提供了 状态机模式，
//所以只有一个启动用的 状态机
export class State_Begin implements tt2.QFrame_IState<MainUI>
{
    app: tt2.QFrame_App<MainUI>;
    inited: boolean = false;
    OnInit(statemgr: tt2.QFrame_App<MainUI>): void {
        this.app = statemgr;

        this.InitAsync();
    }

    async InitAsync() {
        let port = tt2.QExt.GetExtPort();
        if (port == 0)
            port = 8848;
        let b = await tt2.QExt.Init();
        if (b) {
            console.log("==扩展PingCheck")
            tt2.QExt.PingCheck();
        }
        await EUI_Style.Init(this.app.font);
        this.app.debug = false;
        let ui = this.app.getUserData();
        // = new MainUI(this.app.canvas, this.app.font);
        ui.Init(this.app.canvas, this.app.font);



        this.inited = true;
    }
    OnExit(): void {

    }
    OnUpdate(delta: number): void {
        this.app.getUserData().OnUpdate(delta);
    }
    OnRender(): void {

    }

}